package org.data;

import java.io.*;

public class MyMain {

        public static void main(String[] args) throws IOException {

            FileInputStream inputStream = new FileInputStream("D:\\data\\out2\\part-r-00000");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

            BufferedWriter bw =new BufferedWriter(new FileWriter("D:\\data\\text.txt"));

            int count = 4;
            String str = null;
            while((str = bufferedReader.readLine()) != null) {

                String[] s1 = str.split(",");
                String[] s2 =  s1[1].split("\\.");
                Double d1 = 0.0;
                if(!s2[0].equals("null")) {

                    if (s2[0].length()>2) {
                        d1 = Double.parseDouble(s2[0].substring(0, 2));
                        d1 = Normal(d1);
                    }else {
                        d1 = Double.parseDouble(s2[0]);
                        d1 = Normal(d1);
                    }
                    System.out.println(d1);
                }
                for (int i=0; i<count; i++){
                    bw.write(String.valueOf(d1)+"     ");
                    if (i==3){
                        bw.write("\n");
                    }
                }

                bw.flush();
            }

            inputStream.close();
            bufferedReader.close();
            bw.close();
        }
        public static Double Normal(Double x){
            double a=0,b=10;
            x=(x-a)/(b-a);
            return x;
        }

}
